package com.gxuwz.leave.service;

import com.gxuwz.leave.dao.LeaveDao;
import com.gxuwz.leave.entity.Leave;
import com.gxuwz.leave.entity.Student;

import java.util.List;

public class LeaveServiceImpl implements LeaveService{
    private LeaveDao leaveDao;

    @Override
    public void addLeave(Leave entity) {
        leaveDao.insert(entity);
    }

    @Override
    public Leave findLeave(String leaveID) {
        Leave leave = new Leave();
        leave.setLeaveID(leaveID);
        List<Leave> leaves = leaveDao.query(leave);
        if(leaves!=null){
            leave = leaves.get(0);
        }
        return leave;
    }

    @Override
    public void deleteLeave(String leaveID) {
        leaveDao.delete(leaveID);
    }

    @Override
    public List<Leave> list(Leave entity) {
        return leaveDao.query(entity);
    }

    @Override
    public void editLeave(Leave entity) {
        leaveDao.update(entity);
    }

    public void setLeaveDao(LeaveDao leaveDao){
        this.leaveDao = leaveDao;
    }
}
